import React, { Component } from "react";
import LeftMenu from "../components/LeftMenu/index";
import { ConfigProvider, notification, Icon } from "antd";
import zhCN from "antd/es/locale/zh_CN";
import BreadcrumbCmp from "../components/BreadCrumb/Breadcrumb";
import { getDraftPushInfo } from "../services/services";
import { connect } from "dva";
import router from "umi/router";
import "./index.less";
let i = 1;
@connect(({ add }) => ({ add: add }))
class BasicLayout extends Component {
  constructor(props) {
    super(props);
    this.state = {
      timer: null
    };
  }
  componentDidMount() {
    // 获取权限信息
    this.props.dispatch({
      type: "add/getQuanxian",
      payload: {
        data: {
          service_code: "fssupervise"
        }
      }
    });
    let logoInfo = JSON.parse(localStorage.getItem("loginData")) || "";
    if (logoInfo.userInfo && logoInfo.userInfo.id) {
      this.setState({
        // timer: setInterval(function() {
        //   getDraftPushInfo({ user_id: logoInfo.userInfo.id })
        //     .then(res => {
        //       if (res.code === 200 && !!res.data.length) {
        //         res.data.forEach(item => {
        //           let type = "稿件";
        //           if (item.content_type === 1) {
        //             type = "文章";
        //           } else if (item.content_type === 2) {
        //             type = "图集";
        //           } else if (item.content_type === 4) {
        //             type = "视频";
        //           } else if (item.content_type === 10) {
        //             type = "音频";
        //           }
        //           notification.open({
        //             message: `推送${type}标题：${item.title}`,
        //             description: `发布站点：${item.site_name}`,
        //             icon: <Icon type="check-circle" style={{ color: "#52c41a" }} />,
        //             onClick: () => {
        //               router.push(`/City/DistrictContent/${item.site_id}`);
        //             }
        //           });
        //         });
        //       }
        //     })
        //     .catch(err => {
        //       clearInterval();
        //     });
        // }, 10000)
      });
    }
  }
  componentWillUnmount() {
    clearInterval(this.state.timer);
  }
  render() {
    return (
      <ConfigProvider locale={zhCN}>
        {this.props.location.pathname === "/Add" ? (
          <div>{this.props.children}</div>
        ) : (
          <div className="BasicLayout">
            <div className="BasicMenu">
              <LeftMenu parent={this} location={this.props.location} />
            </div>
            <div className="BasicMain">{this.props.children}</div>
            <div id="fcUpload"></div>
          </div>
        )}
      </ConfigProvider>
    );
  }
}

export default BasicLayout;
